package com.xiyin.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xiyin.entity.User1;
import com.xiyin.mapper.User1Mapper;
import com.xiyin.service.IUser1Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author xukaihang
 * @since 2024-08-18
 */
@Service
public class User1ServiceImpl extends ServiceImpl<User1Mapper, User1> implements IUser1Service {
    @Autowired
    private User1Mapper user1Mapper;

    @Override
    public List<User1> getUserByLambdaQueryWrapper() {
        return user1Mapper.selectList(new LambdaQueryWrapper<User1>()
                //等于
                .eq(User1::getUserName, "lisi4")
                //大于
                .gt(User1::getAge, 18));
    }

    @Override
    public List<User1> getUserBylambdaByOrQueryWrapper() {
        //SELECT id,USER_NAME,AGE,EMAIL,CREATE_TIME,UPDATE_TIME,STATUS FROM user_1 WHERE STATUS='0' AND (USER_NAME = ? OR AGE > ?)
        return user1Mapper.selectList(new LambdaQueryWrapper<User1>()
                .eq(User1::getUserName, "lisi4")
                .or()
                .gt(User1::getAge, 18));
    }
}
